﻿using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MesTool
{
    public class OrderBLL
    {
        private ConnectionConfig connection = null;
        public SqlSugarClient db = null;
        public OrderBLL()
        {
            string SqlIP = "192.168.2.8";
            string database = "EdgeDB";
            string uid = "sa";
            string pwd = "8ik,9ol.";
            connection = new ConnectionConfig()
            {
                ConnectionString = "server='" + SqlIP + "';initial catalog='" + database + "';uid='" + uid + "';pwd='" + pwd + "'",
                DbType = DbType.SqlServer,
                IsAutoCloseConnection = true,
                InitKeyType = InitKeyType.Attribute
            };
            db = new SqlSugarClient(connection);
        }
        public int GetQty(string mocode)
        {
            try
            {
                Model.MesDb.order_work model = db.Queryable<Model.MesDb.order_work>().Where(it => it.number == mocode).First();
                if (model == null)
                {
                    return 0;
                }
                string qty = model.plan_qty;
                return (int)double.Parse(qty);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
    }
    
}
